<%--
  Created by IntelliJ IDEA.
  User: MACHENIKE
  Date: 2022/8

  13
  Time: 12:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
    <title>主页</title>
    <script src="js/jquery3.1.1.js"></script>
</head>
<body>
<h1>图书系统欢迎${username}的使用</h1>
<a href="Add.jsp">添加</a>
<form action="/Book/queryBooks.do">
    请输入书名：<input name="bookname" value="${bookname}" id="bookname">
    <input type="submit" value="查询">
</form>

<div>
    <table border="1px" align="center" cellpadding="0px" cellspacing="0px" width="50%">
        <tr>
            <th>书名</th>
            <th>作者</th>
            <th>出版社</th>
            <th>日期</th>
            <th>页数</th>
            <th>价格</th>
            <th>内容摘要</th>
            <th>操作</th>
        </tr>
        <c:forEach var="book" items="${books}">
        <tr>
            <td>${book.name}</td>
            <td>${book.author}</td>
            <td>${book.publish}</td>
            <td>
<%--                <input type="text" value="<fmt:formatDate--%>
<%--                value="${book.publishdate}" pattern="yyyy-mm-dd"/>"></td>--%>
<%--    导入时间工具标签--%>
<%--    <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>--%>
                <fmt:formatDate
                value="${book.publishdate}" pattern="yyyy-mm-dd"/></td>
            <td>${book.page}</td>
            <td>${book.price}</td>
            <td>${book.content}</td>
            <td>
                <a href="/Book/queryBookById.do?id=${book.id}">修改</a>
                <a href="javascript:deleteBook(${book.id})">删除</a>
            </td>
        </tr>
        </c:forEach>
        <tr>
            <td colspan="8">
                第<span>${pageInfo.pageNum}</span>页/共<span>${pageInfo.pages}</span>页,共<span>${pageInfo.total}</span>条

                <a href="/Book/queryBooks.do?pageNum=1&bookname=${bookname}">首页</a>
                <a href="/Book/queryBooks.do?pageNum=${pageInfo.prePage}&bookname=${bookname}">上一页</a>
                <a href="/Book/queryBooks.do?pageNum=${pageInfo.nextPage}&bookname=${bookname}">下一页</a>
                <a href="/Book/queryBooks.do?pageNum=${pageInfo.pages}&bookname=${bookname}">末页</a>
            </td>
        </tr>
    </table>
</div>
    <script>
        function deleteBook(id) {
            alert(id)
            var falg = confirm("确认要删除?")

            if(falg){
                window.location = "http://localhost:8080/Book/deleteBook.do?id="+id;
            }
        }
    </script>

</body>
</html>
